const Promise = require('bluebird');
const models = require('../../src/models');
const mysqlConfig = require('../../config').mysql;
const dicts = require('./data/dicts.json');
const instance = models.newInstance(mysqlConfig);
const Dicts = instance.Dicts;

Promise.map(dicts, function (dict) {
    return Dicts.findOne({where: {type: dict.type, value: dict.value}}).then(function (d) {
        if (!d) {
            return Dicts.create(dict);
        }
    });
}, {concurrency: 1});
